#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
using namespace std;


int main3753()
{
	string sourceStr;
	
	sourceStr = "";
	cout << sourceStr.size() << endl;
	while(getline(cin,sourceStr))
	{
		cout << sourceStr.size() << endl;
		cout << (sourceStr == "") << endl;
	}
	while (getline(cin,sourceStr,'\n'))
	{

		string patternStr = "";
		while (getline(cin,patternStr,'\n'))
		{
			if (patternStr == "END")
			{
				break;
			}
			if (patternStr == "NULL")
			{
				cout << "0 NULL" << endl;
				continue;
			}

			if (patternStr == "" || patternStr.size() == 0)
			{
				cout << sourceStr.size() << " " << sourceStr << endl;
				continue;
			}

			int idx = sourceStr.find(patternStr);
			if (idx == string::npos)
			{
				cout << sourceStr.size() << " " << sourceStr << endl;
				continue;
			}
			if (idx == 0)
			{
				cout << "0 NULL" << endl;
				continue;
			}
			string subStr = sourceStr.substr(0,idx);
			cout << subStr.size() << " " << subStr << endl;
		}
		
	}
	return 0;
}